from django.views.generic import ListView, DetailView, CreateView, \
                                 DeleteView, UpdateView, \
                                 ArchiveIndexView, DateDetailView, \
                                 DayArchiveView, MonthArchiveView, \
                                 TodayArchiveView, WeekArchiveView, \
                                 YearArchiveView


from weather.models import EventsOfficial


class EventsOfficialView(object):
    model = EventsOfficial

    def get_template_names(self):
        """Nest templates within eventsofficial directory."""
        tpl = super(EventsOfficialView, self).get_template_names()[0]
        app = self.model._meta.app_label
        mdl = 'eventsofficial'
        self.template_name = tpl.replace(app, '{0}/{1}'.format(app, mdl))
        return [self.template_name]


class EventsOfficialDateView(EventsOfficialView):
    date_field = 'start_time'
    month_format = '%m'


class EventsOfficialBaseListView(EventsOfficialView):
    paginate_by = 10


class EventsOfficialArchiveIndexView(
    EventsOfficialDateView, EventsOfficialBaseListView, ArchiveIndexView):
    pass


class EventsOfficialCreateView(EventsOfficialView, CreateView):
    pass


class EventsOfficialDateDetailView(EventsOfficialDateView, DateDetailView):
    pass


class EventsOfficialDayArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, DayArchiveView):
    pass


class EventsOfficialDeleteView(EventsOfficialView, DeleteView):

    def get_success_url(self):
        from django.core.urlresolvers import reverse
        return reverse('weather_eventsofficial_list')


class EventsOfficialDetailView(EventsOfficialView, DetailView):
    pass


class EventsOfficialListView(EventsOfficialBaseListView, ListView):
    pass


class EventsOfficialMonthArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, MonthArchiveView):
    pass


class EventsOfficialTodayArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, TodayArchiveView):
    pass


class EventsOfficialUpdateView(EventsOfficialView, UpdateView):
    pass


class EventsOfficialWeekArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, WeekArchiveView):
    pass


class EventsOfficialYearArchiveView(
    EventsOfficialDateView, EventsOfficialBaseListView, YearArchiveView):
    make_object_list = True



